package com.ce.cases.assit.action;


import java.util.Date;

import com.ce.cases.assit.dao.po.CaseAssitCheck;
import com.ce.framework.datamaintain.action.DataMaintainAction;
import com.ce.framework.datamaintain.dao.po.AbstractPO;
import com.ce.framework.exception.AppException;
import com.ce.framework.util.BeanAccessUtil;
import com.ce.sys.login.model.User;


/**
* 嫦娥软件有限公司 版权所有 2013
* 创建人：　andy
* 创建日期：2014-03-25
* 创建时间：13:23:23
* 功能描述：受托协查台账 [CASE_ASSIT_CHECK]更改时用的Action
* ==============================================
* 修改历史
* 修改人		修改时间		修改原因
*
* ==============================================
*/
public class CaseAssitCheckAction extends DataMaintainAction 
{
	private static final long serialVersionUID = 1L;

	@Override
	protected String addItem() throws AppException {
		try {
			BeanAccessUtil.copyProperty(po, "registerDate", new Date());
			BeanAccessUtil.copyProperty(po, "registerPerson",User.getUserName());
			BeanAccessUtil.copyProperty(po, "registerDeptId",User.getUserOrgId());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return super.addItem();
	}

	@Override
	protected String modifyItem() throws AppException {
		CaseAssitCheck entiy = (CaseAssitCheck) this.baselogic.getPOByPk(po.getClass().getName(), po.getVcId());
		BeanAccessUtil.copyNoCopyNullProperty(po, entiy);
		this.baselogic.updatePo(entiy, this.getAddList(), this.getModifyList(),this.getDeleteList());
		return super.searchData();
	}

	/**
	 * 打开回复操作页
	 */
	public String replyPage() throws AppException {
		String vcId = this.getSelectId();
	    try {
	    	po=(AbstractPO)this.baselogic.getPOByPk(po.getClass().getName(), vcId);
	    	CaseAssitCheck check=(CaseAssitCheck)po;
	    	if(check.getReplyDate()==null)
			    BeanAccessUtil.copyProperty(po, "replyDate", new Date());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "openReplyPage";
	}

	/**
	 * 回复保存
	 */
	public String dealReply() {
		try {
			CaseAssitCheck savePo = (CaseAssitCheck) this.baselogic.getPOByPk(po.getClass().getName(), po.getVcId());
			//注：修改时无法拷贝置空(非必填项)的数据，适合数据添加
			BeanAccessUtil.copyNoCopyNullProperty(po, savePo);
			this.baselogic.updatePo(savePo);
		} catch (AppException e) {
			e.printStackTrace();
			return this.returnInfoForJS(false, e.getMessage());
		}
		return this.returnInfoForJS(true, "回复情况保存成功！");
	}

	/**
	 * 打开入库情况操作页
	 */
	public String inWareHousePage() throws AppException {
		String vcId = this.getSelectId();
	    po=(AbstractPO)this.baselogic.getPOByPk(po.getClass().getName(), vcId);
		return "openInWarehousePage";
	}

	/**
	 * 入库情况处理
	 */
	public String dealInResult() throws AppException {
		try {
			CaseAssitCheck savePo = (CaseAssitCheck) this.baselogic.getPOByPk(po.getClass().getName(), po.getVcId());
			//注：修改时无法拷贝置空(非必填项)的数据，适合数据添加
			BeanAccessUtil.copyNoCopyNullProperty(po, savePo);
			this.baselogic.updatePo(savePo);
		} catch (AppException e) {
			e.printStackTrace();
			return this.returnInfoForJS(false, e.getMessage());
		}
		return this.returnInfoForJS(true, "入库情况保存成功！");
	}
}

